# mysql 为安装mysql的docker
#!/bin/bash
docker_name=mysql57
data_dir="/home/docker-lnmp/backup/mysql57"
docker exec -it ${docker_name} mysqldump -uroot -proot -P7306 --all-databases > "${data_dir}/backup_`date +%Y_%m_%d_%H_%M_%S`.sql"

mkdir -p ${data_dir}

save_days=200
# 删除7天以前的备份
find ${data_dir} -mtime +${save_days} -name 'backup_*.sql' -exec rm -rf {} \;